<?php
if(isset($_GET["sub"])){
	//导入数据库配置文件
	require("../../conn/conn.php");
	$id = $_GET["par_id"];
	$pwd = $_GET["par_pwd"];
	$name = $_GET["par_child_name"];
	$age = $_GET["par_child_age"];
	$sex = $_GET["par_child_sex"];
	
	if(strlen($id) == 11){
		if(strlen($pwd)>=6 && strlen($pwd)<=20){
			//基本信息插入数据库
			$sql_insert = "INSERT INTO `par_info` (`par_id`, `par_pwd`, `par_child_name`, `par_child_age`, `par_child_sex`)
			VALUES ('$id','$pwd', '$name', '$age', '$sex')";
			//执行判断
			if(mysqli_query($conn,$sql_insert)){
				echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."注册成功"."\"".")".";"."</script>";
				echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."../html/家长注册.html"."\""."</script>";
			}else{
				echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."该手机号已注册，请"."\"".")".";"."</script>";
				echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."../html/家长注册.html"."\""."</script>";
			}	
		}else{
			echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."密码格式输入不正确"."\"".")".";"."</script>";
			echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."../html/家长注册.html"."\""."</script>";
		}
	}else{
		echo"<script type="."\""."text/javascript"."\"".">"."window.alert"."("."\""."手机号格式输入不正确"."\"".")".";"."</script>";
		echo"<script type="."\""."text/javascript"."\"".">"."window.location="."\""."../html/家长注册.html"."\""."</script>";
	}
}